/**
 * Created by dev-001 on 2017/3/23.
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

/**
 * 同一个老师，在不同学校，不同年级，不同班级任教
 * 同一个学生，在某个学校，某个年级，某个班级
 */
const TeacherRolerSchema = new Schema({
    teacher: {
        type: ObjectId,
        ref: 'User'
    },
    school: {
        type: ObjectId,
        ref: 'School'
    },
    roler: {
        type: ObjectId,
        ref: 'Roler'
    },
    current: Boolean,
    status: Boolean,
    createdAt: Date,
    updatedAt: Date
});

TeacherRolerSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('TeacherRoler', TeacherRolerSchema);